<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Consultar Notas e Frequencia</title>
    </head>
    <body>
        <h1>Consultar Notas e Frequencia</h1>
        <s:form action="NotaFrequencia">
            <table>
                <tr>
                    <td>Aluno:</td>
                    <td>
                        <s:hidden name="matriculaAluno" value="%{aluno.matricula}"></s:hidden>
                        ${aluno.nome}</td>
                </tr>
                <tr>
                    <td>Listar:</td>
                    <td>
                        <s:radio name="pesquisa" list="pesquisaList" onclick="desabilita(this)"></s:radio>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <s:select name="ano" list="anos" id="ano" label="Ano" disabled="true"></s:select>
                        <s:select name="semestre" id="semestre" list="semestres" label="Semestre" disabled="true"></s:select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <s:submit action="consultarNotaFrequencia" value="Pesquisar"></s:submit>
                        </td>
                    </tr>
                </table>

                <table border>
                    <tr>
                        <td>COD. DISCIPLINA</td><td>PERIODO</td><td>DISCIPLINA</td><td>FALTAS</td><td>NOTA 1</td>
                        <td>NOTA 2</td><td>PROVA FINAL</td><td>MEDIA</td><td>NOTA FINAL</td><td>RESULTADO FINAL</td>
                    </tr>
                <s:iterator value="avaliacoes">
                    <tr>
                        <td>${turma.disciplina.codDisciplina}</td>
                        <td>${turma.disciplina.periodo}</td>
                        <td>${turma.disciplina.nome}</td>
                        <td>${numFaltas}</td>
                        <td>${nota1}</td>
                        <td>${nota2}</td>
                        <td>${notaProvaFinal}</td>
                        <td>${(nota1 + nota2)/2}</td>
                        <td>
                            <s:if test="%{(nota1 + nota2)/2 >= notaProvaFinal}">${(nota1 + nota2)/2}</s:if>
                            <s:elseif test="%{(nota1 + nota2)/2 < notaProvaFinal}">60</s:elseif>
                            </td>
                            <td>
                            <s:if test="%{nota1}">
                                <s:if test="%{nota2}">
                                    <s:if test="%{notaProvaFinal}">
                                        <s:if test="%{notaProvaFinal >= 60">APROVADO</s:if>
                                        <s:else>REPROVADO</s:else>
                                    </s:if>
                                    <s:else>
                                        <s:if test="%{((nota1 + nota2)/2) >= 60}">APROVADO</s:if>
                                        <s:elseif test="%{((nota1 + nota2)/2)<40}">REPROVADO</s:elseif>
                                        <s:else>PROVA FINAL</s:else>
                                    </s:else>
                                </s:if>
                            </s:if>

                        </td>
                        </tr>
                </s:iterator>
            </table>
                        <s:submit action="voltarNotaFrequencia" value="voltar"></s:submit>
        </s:form>

    <script language="JavaScript">
        //<!---
        function desabilita(radio) {
            if (radio.value == "Todas") {
                document.getElementById("ano").setAttribute("disabled", true);
                document.getElementById("semestre").setAttribute("disabled", true);
                document.getElementById("pesquisa").setAttribute("value", "Todas");
            } else {
                document.getElementById("ano").removeAttribute("disabled");
                document.getElementById("semestre").removeAttribute("disabled");
                document.getElementById("pesquisa").setAttribute("value", "Ano");
            }

            return true;
        }
        //--->
    </script>
</html>




